<template>
  <PickChoiceOss :apis="api" :isSingle="props.isSingle" @selected="($event) => { emit('selected', $event) }"
    :accessToken="accessToken" :templateModel="props.templateModel" :closeModel="props.closeModel"
    :initialize="props.initialize" :action="uploadFile" />
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import { deleteFile, renameFile, getFileDirectory, addFileDirectory, updateFileDirectory, delFileDirectory } from '@/api/index';
import { getFileListData } from '@/api/setting';
import uploadFile from '@/api/index';
import { PickChoiceOss } from '@pickmall/ui-v3-components'
import store from '@/utils/storage';
const accessToken = ref(store.getAccessToken());
const api = {
  init: getFileListData,
  rename: renameFile,
  delete: deleteFile,
  initDir: getFileDirectory,
  addDir: addFileDirectory,
  updateDir: updateFileDirectory,
  delDir: delFileDirectory,
}
const emit: any = defineEmits<{
  (e: 'selected', val: any, type: string): void;
}>();
const props = defineProps({
  // 是否单选
  isSingle: {
    type: Boolean,
    default: false
  },
  // 组件模式
  templateModel: {
    type: String,
    default: 'normal',
  },
  closeModel: {
    type: null
  },
  initialize: {
    type: Boolean,
    default: false,
  },
});
</script>
